package com.sc.nft.admin.request.ecologypool;

import com.sc.nft.enums.ecologypool.EcologyPoolRedPackAuditStatusEnum;
import com.sc.nft.exception.GlobalRunTimeException;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;

import javax.validation.constraints.NotNull;
import java.io.Serializable;


@Data
public class EcologyPoolRedPackAuditRequest implements Serializable {

    @ApiModelProperty("id")
    @NotNull(message = "id不能为空")
    private Long id;

    @ApiModelProperty("审核状态")
    @NotNull(message = "审核状态不能为空")
    private EcologyPoolRedPackAuditStatusEnum auditStatus;

    @ApiModelProperty("拒绝原因")
    private String rejectReason;


    public void checkRejectReason() {
        if (auditStatus != EcologyPoolRedPackAuditStatusEnum.REVIEW_REJECTED) {
            return;
        }
        if (StringUtils.isBlank(rejectReason)) {
            throw new GlobalRunTimeException("拒绝原因不能为空!");
        }
        if (rejectReason.length() > 50) {
            throw new GlobalRunTimeException("拒绝原因不能超过50个字");
        }
    }

}
